/**
 * 
 */
package com.psytech.app.task.web_ui.server;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.psytech.app.task.web_ui.driver.TaskDriverInterface;
import com.psytech.app.task.web_ui.driver.UserDriverInterface;

/**
 * @author ben
 * 
 */
public class ServiceLocator {

	private static ApplicationContext springContext;

	private static ApplicationContext getInstance() {
		if (springContext == null)
			synchronized (ServiceLocator.class) {
				if (springContext == null)
					springContext = new ClassPathXmlApplicationContext("com/psytech/app/task/web_ui/spring.xml");
			}
		return springContext;
	}

	public static TaskDriverInterface getTaskDriver() {
		return (TaskDriverInterface) ServiceLocator.getInstance().getBean("taskDriver");
	}

	public static UserDriverInterface getUserDriver() {
		return (UserDriverInterface) ServiceLocator.getInstance().getBean("userDriver");
	}

	public static String getSmtpHost() {
		return (String) ServiceLocator.getInstance().getBean("smtpHost");
	}

	public static String getDefaultSender() {
		return (String) ServiceLocator.getInstance().getBean("smtpSender");
	}
}
